package com.ezonsport.android.ui;

import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;
import android.util.Log;

import com.ezonsport.android.R;

public class UserInformationSettings extends PreferenceActivity implements OnPreferenceChangeListener{
	private static final String TAG="UserInformationSettings";
	private static final String USER_HEIGHT = "user_height";
	private static final String USER_WEIGHT = "user_weight";
	private static final String USER_GENDER = "user_gender";
	private EditTextPreference m_heightPreference;
	private EditTextPreference m_weightPreference;
	private ListPreference m_genderPreference;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.user_information_settings);
        m_heightPreference = (EditTextPreference)findPreference("user_height");
        m_weightPreference = (EditTextPreference)findPreference("user_weight");
        m_genderPreference = (ListPreference)findPreference("user_gender");
        m_heightPreference.setOnPreferenceChangeListener(this);
        m_weightPreference.setOnPreferenceChangeListener(this);
        m_genderPreference.setOnPreferenceChangeListener(this);
    }
    
    public boolean onPreferenceChange(Preference preference, Object newValue){
    	String key = preference.getKey();
    	if(key.equals(USER_HEIGHT))
    		m_heightPreference.setSummary((String)newValue);
    	if(key.equals(USER_WEIGHT))
    		m_weightPreference.setSummary((String)newValue);
    	if(key.equals(USER_GENDER))
    		m_genderPreference.setSummary((String)newValue);
    	
    	return false;
    }
}
